<?php
$username = $_GET['username'];
$password = $_GET['password'];
if ($username == ''){
    echo "请输入用户名！";
    exit(0);
}
if ($password == ''){
    echo "请输入密码";
    exit(0);
}

    $conn = new mysqli('localhost','root','123456','zb');
    if ($conn->connect_error){
        echo '数据库连接失败！';
        exit(0);
    }else {
        $sql = "select * from login where user = '$username'";
        $result = $conn->query($sql);
        $number = mysqli_num_rows($result);
        if ($number) {
            //$sql_insert = "select pass from login where user = $username";
            $row = mysqli_fetch_assoc($result);
            //$res_insert = $conn->query($sql_insert);
            if ($row["pass"] == $password) {
                echo '登录成功';
            } else {
                echo "密码错误";
            }
        } else {
            echo "此账号不存在";
        }
    }

?>
